package com.cn.zmc.design.builder.controller;


import com.cn.zmc.design.builder.service.BuilderService;
import com.cn.zmc.design.builder.service.domain.RiskData;
import com.cn.zmc.design.builder.service.domain.RiskOrder;
import com.cn.zmc.design.builder.service.domain.RiskPhone;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("build")
public class BuildController {

    @Autowired
    private BuilderService builderService;

    @RequestMapping("test")
    public String test() {
        //造数据(从第三方传入数据)
        RiskOrder riskOrder = new RiskOrder();
        riskOrder.setOrderId((int)(Math.random() * 100));
        riskOrder.setUserName("张三");
        riskOrder.setUserId((int)(Math.random() * 100));
        RiskPhone riskPhone = new RiskPhone();
        riskPhone.setPhone("13777777777");
        riskPhone.setId((int)(Math.random() * 100));
        RiskData riskData = new RiskData();
        riskData.setOrder(riskOrder);
        riskData.setPhone(riskPhone);
        //验证数据合法性,并入库
        RiskData build = builderService.create().order(riskData.getOrder()).phone(riskData.getPhone()).build();
        System.out.println(build.toString());
        return "ok";
    }
}
